From 645d487efc0afb1ee33ad998a712c85dfe0277ed Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 25 Jul 2011 02:42:00 +0000 Subject: [PATCH] A bulky, but relatively brute force, attempt to make an interesting part of the code base legal C and C++ at the same time. This means that things are quite non-C++ right now, but you can only fight battles on so many fronts... --- gpsbabel/GPSBabel.pro | 96 +++++++++++++++++----------------- gpsbabel/an1.c | 10 ++-- gpsbabel/an1sym.h | 2 +- gpsbabel/avltree.c | 4 +- gpsbabel/cet/ansi_x3_4_1968.h | 4 +- gpsbabel/cet/ibm891.h | 4 +- gpsbabel/cet/ibm903.h | 4 +- gpsbabel/cet/iso_8859_1.h | 4 +- gpsbabel/cet_util.c | 7 +-- gpsbabel/cetus.c | 4 +- gpsbabel/copilot.c | 2 +- gpsbabel/csv_util.c | 2 +- gpsbabel/defs.h | 27 ++++++++-- gpsbabel/garmin.c | 8 +-- gpsbabel/garmin_device_xml.c | 4 +- gpsbabel/garmin_tables.c | 2 +- gpsbabel/gbfile.c | 22 ++++---- gpsbabel/gbser_posix.c | 2 +- gpsbabel/geo.c | 4 +- gpsbabel/gpspilot.c | 2 +- gpsbabel/gpx.c | 24 ++++----- gpsbabel/gtm.c | 4 +- gpsbabel/inifile.c | 4 +- gpsbabel/itracku.c | 6 +-- gpsbabel/jeeps/garminusb.h | 6 ++- gpsbabel/jeeps/gps.h | 12 ++--- gpsbabel/jeeps/gpsapp.c | 6 ++- gpsbabel/jeeps/gpscom.c | 8 +-- gpsbabel/jeeps/gpsdevice_usb.c | 2 + gpsbabel/jeeps/gpslibusb.c | 23 ++++---- gpsbabel/jeeps/gpsprot.c | 1 + gpsbabel/jeeps/gpsprot.h | 96 ++++++++++++++++++---------------- gpsbabel/jeeps/gpsserial.c | 2 +- gpsbabel/jeeps/gpsusbcommon.c | 2 +- gpsbabel/kml.c | 3 +- gpsbabel/magproto.c | 18 +++---- gpsbabel/make-an1sym.pl | 2 +- gpsbabel/mapsource.c | 2 +- gpsbabel/mkshort.c | 47 ++++++----------- gpsbabel/nmea.c | 2 +- gpsbabel/psp.c | 2 +- gpsbabel/trackfilter.c | 4 +- gpsbabel/vmem.c | 4 +- gpsbabel/waypt.c | 6 +-- gpsbabel/wbt-200.c | 14 ++--- 45 files changed, 268 insertions(+), 246 deletions(-) diff --git a/gpsbabel/GPSBabel.pro b/gpsbabel/GPSBabel.pro index 6d4cd5fbd..f8183cc91 100644 --- a/gpsbabel/GPSBabel.pro +++ b/gpsbabel/GPSBabel.pro @@ -6,66 +6,66 @@ CONFIG -= app_bundle TEMPLATE = app -MINIMAL_FMTS = magproto.c gpx.c geo.c mapsend.c mapsource.c garmin.c \ - garmin_device_xml.c garmin_tables.c internal_styles.c nmea.c \ - kml.c wbt-200.c - -ALL_FMTS=$$MINIMAL_FMTS gtm.c gpsutil.c pcx.c cetus.c copilot.c \ - gpspilot.c magnav.c skytraq.c \ - psp.c holux.c tmpro.c tpg.c tpo.c \ - xcsv.c gcdb.c tiger.c easygps.c quovadis.c \ - gpilots.c saroute.c navicache.c psitrex.c geoniche.c delgpl.c \ - ozi.c text.c html.c palmdoc.c netstumbler.c hsa_ndv.c \ - igc.c brauniger_iq.c shape.c hiketech.c glogbook.c coastexp.c \ - vcf.c overlay.c google.c xhtmlent.c lowranceusr.c an1.c tomtom.c \ - tef_xml.c maggeo.c pathaway.c vitosmt.c gdb.c bcr.c coto.c \ - ignrando.c stmwpp.c msroute.c cst.c nmn4.c mag_pdb.c compegps.c \ - yahoo.c unicsv.c wfff_xml.c garmin_txt.c axim_gpb.c gpssim.c \ - stmsdf.c gtrnctr.c dmtlog.c raymarine.c alan.c vitovtt.c \ - ggv_log.c g7towin.c garmin_gpi.c lmx.c random.c xol.c dg-100.c \ - navilink.c mtk_logger.c ik3d.c osm.c destinator.c exif.c vidaone.c \ - igo8.c gopal.c humminbird.c mapasia.c gnav_trl.c navitel.c ggv_ovl.c \ - jtr.c sbp.c sbn.c mmo.c skyforce.c itracku.c v900.c delbin.c \ - pocketfms_bc.c pocketfms_fp.c pocketfms_wp.c naviguide.c enigma.c \ - vpl.c teletype.c jogmap.c bushnell.c bushnell_trl.c wintec_tes.c \ - subrip.c garmin_xt.c explorist_ini.c \ - -FILTERS=position.c radius.c duplicate.c arcdist.c polygon.c smplrout.c \ - reverse_route.c sort.c stackfilter.c trackfilter.c discard.c \ - nukedata.c interpolate.c transform.c height.c swapdata.c - -SHAPE=shapelib/shpopen.c shapelib/dbfopen.c pdbfile.c +XMINIMAL_FMTS = magproto.cc gpx.cc geo.cc mapsend.cc mapsource.cc garmin.cc \ + garmin_device_xml.cc garmin_tables.cc internal_styles.cc nmea.cc \ + kml.cc wbt-200.cc + +XALL_FMTS=$$MINIMAL_FMTS gtm.cc gpsutil.cc pcx.cc cetus.cc copilot.cc \ + gpspilot.cc magnav.cc skytraq.cc \ + psp.cc holux.cc tmpro.cc tpg.cc tpo.cc \ + xcsv.cc gcdb.cc tiger.cc easygps.cc quovadis.cc \ + gpilots.cc saroute.cc navicache.cc psitrex.cc geoniche.cc delgpl.cc \ + ozi.cc text.cc html.cc palmdoc.cc netstumbler.cc hsa_ndv.cc \ + igc.cc brauniger_iq.cc shape.cc hiketech.cc glogbook.cc coastexp.cc \ + vcf.cc overlay.cc google.cc xhtmlent.cc lowranceusr.cc an1.cc tomtom.cc \ + tef_xml.cc maggeo.cc pathaway.cc vitosmt.cc gdb.cc bcr.cc coto.cc \ + ignrando.cc stmwpp.cc msroute.cc cst.cc nmn4.cc mag_pdb.cc compegps.cc \ + yahoo.cc unicsv.cc wfff_xml.cc garmin_txt.cc axim_gpb.cc gpssim.cc \ + stmsdf.cc gtrnctr.cc dmtlog.cc raymarine.cc alan.cc vitovtt.cc \ + ggv_log.cc g7towin.cc garmin_gpi.cc lmx.cc random.cc xol.cc dg-100.cc \ + navilink.cc mtk_logger.cc ik3d.cc osm.cc destinator.cc exif.cc vidaone.cc \ + igo8.cc gopal.cc humminbird.cc mapasia.cc gnav_trl.cc navitel.cc ggv_ovl.cc \ + jtr.cc sbp.cc sbn.cc mmo.cc skyforce.cc itracku.cc v900.cc delbin.cc \ + pocketfms_bc.cc pocketfms_fp.cc pocketfms_wp.cc naviguide.cc enigma.cc \ + vpl.cc teletype.cc jogmap.cc bushnell.cc bushnell_trl.cc wintec_tes.cc \ + subrip.cc garmin_xt.cc explorist_ini.cc \ +ALL_FMTS=$$MINIMAL_FMTS +FILTERS=position.cc radius.cc duplicate.cc arcdist.cc polygon.cc smplrout.cc \ + reverse_route.cc sort.cc stackfilter.cc trackfilter.cc discard.cc \ + nukedata.cc interpolate.cc transform.cc height.cc swapdata.cc + +SHAPE=shapelib/shpopen.c shapelib/dbfopen.c pdbfile.cc ZLIB=zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/inffast.c \ zlib/inflate.c zlib/infback.c zlib/inftrees.c zlib/trees.c \ zlib/uncompr.c zlib/gzio.c zlib/zutil.c -JEEPS += jeeps/gpsapp.c jeeps/gpscom.c \ - jeeps/gpsmath.c jeeps/gpsmem.c \ - jeeps/gpsprot.c jeeps/gpsread.c \ - jeeps/gpsdevice.c jeeps/gpsdevice_ser.c jeeps/gpsdevice_usb.c \ - jeeps/gpsrqst.c jeeps/gpssend.c jeeps/gpsserial.c jeeps/jgpsutil.c \ - jeeps/gpsusbread.c jeeps/gpsusbsend.c \ - jeeps/gpsusbcommon.c +JEEPS += jeeps/gpsapp.cc jeeps/gpscom.cc \ + jeeps/gpsmath.cc jeeps/gpsmem.cc \ + jeeps/gpsprot.cc jeeps/gpsread.cc \ + jeeps/gpsdevice.cc jeeps/gpsdevice_ser.cc jeeps/gpsdevice_usb.cc \ + jeeps/gpsrqst.cc jeeps/gpssend.cc jeeps/gpsserial.cc jeeps/jgpsutil.cc \ + jeeps/gpsusbread.cc jeeps/gpsusbsend.cc \ + jeeps/gpsusbcommon.cc -SUPPORT = queue.c route.c waypt.c filter_vecs.c util.c vecs.c mkshort.c \ - csv_util.c strptime.c grtcirc.c vmem.c util_crc.c xmlgeneric.c \ - uuid.c formspec.c xmltag.c cet.c cet_util.c fatal.c rgbcolors.c \ - inifile.c garmin_fs.c gbsleep.c units.c gbser.c \ - gbfile.c parse.c avltree.c session.c main.c globals.c +SUPPORT = queue.cc route.cc waypt.cc filter_vecs.cc util.cc vecs.cc mkshort.cc \ + csv_util.cc strptime.c grtcirc.cc vmem.cc util_crc.cc xmlgeneric.cc \ + uuid.cc formspec.cc xmltag.cc cet.cc cet_util.cc fatal.cc rgbcolors.cc \ + inifile.cc garmin_fs.cc gbsleep.cc units.cc gbser.cc \ + gbfile.cc parse.cc avltree.cc session.cc main.cc globals.cc SUBDIRS += jeeps macx|linux { DEFINES += HAVE_NANOSLEEP HAVE_LIBUSB HAVE_LIBEXPAT HAVE_GLOB DEFINES += HAVE_VA_COPY HAVE_VA_LIST_AS_ARRAY - SOURCES += gbser_posix.c jeeps/gpslibusb.c + SOURCES += gbser_posix.cc jeeps/gpslibusb.cc INCLUDEPATH += jeeps LIBS += -lexpat } win32 { - SOURCES += gbser_win32.c jeeps/gpsusbwin.c + SOURCES += gbser_win32.cc jeeps/gpsusbwin.c } linux { @@ -85,9 +85,9 @@ macx { SOURCES += $$ALL_FMTS $$FILTERS $$SUPPORT $$SHAPE $$ZLIB $$JEEPS # We don't care about stripping things out of the build. Full monty, baby. -DEFINES += MAXIMAL_ENABLED +#DEFINES += MAXIMAL_ENABLED DEFINES += FILTERS_ENABLED -DEFINES += PDBFMTS_ENABLED -DEFINES += SHAPELIB_ENABLED -DEFINES += CSVFMTS_ENABLED -DEFINES += CET_WANTED +#DEFINES += PDBFMTS_ENABLED +#DEFINES += SHAPELIB_ENABLED +#DEFINES += CSVFMTS_ENABLED +#DEFINES += CET_WANTED diff --git a/gpsbabel/an1.c b/gpsbabel/an1.c index ea87f6d8b..583c8a2c7 100644 --- a/gpsbabel/an1.c +++ b/gpsbabel/an1.c @@ -400,7 +400,7 @@ static void Read_AN1_Waypoint(gbfile *f, an1_waypoint_record *wpt) *oldurlstr = 0; } - wpt->url = xcalloc(len+1, 1); + wpt->url = (char*) xcalloc(len+1, 1); memcpy(wpt->url, ofs, len); ofs += len; } @@ -409,7 +409,7 @@ static void Read_AN1_Waypoint(gbfile *f, an1_waypoint_record *wpt) ofs += 2; if (len) { - wpt->comment = xcalloc(len+1, 1); + wpt->comment = (char*) xcalloc(len+1, 1); memcpy(wpt->comment, ofs, len); ofs += len; } @@ -769,7 +769,7 @@ Write_One_AN1_Waypoint(const waypoint *wpt) rec->name = xstrdup(wpt->description); if (!nogc && wpt->gc_data->id) { - char *extra = xmalloc(25 + strlen(wpt->gc_data->placer) + strlen(wpt->shortname)); + char *extra = (char *) xmalloc(25 + strlen(wpt->gc_data->placer) + strlen(wpt->shortname)); sprintf(extra, "\r\nBy %s\r\n%s (%1.1f/%1.1f)", wpt->gc_data->placer, wpt->shortname, wpt->gc_data->diff/10.0, @@ -1239,9 +1239,9 @@ my_write(void) ff_vecs_t an1_vecs = { ff_type_file, { - ff_cap_read | ff_cap_write /* waypoints */, + (ff_cap) (ff_cap_read | ff_cap_write) /* waypoints */, ff_cap_write /* tracks */, - ff_cap_read | ff_cap_write /* routes */, + (ff_cap) (ff_cap_read | ff_cap_write) /* routes */, }, rd_init, wr_init, diff --git a/gpsbabel/an1sym.h b/gpsbabel/an1sym.h index 22d0a9af1..3904fad27 100644 --- a/gpsbabel/an1sym.h +++ b/gpsbabel/an1sym.h @@ -62,7 +62,7 @@ struct defguid { GUID guid; - char *name; + const char *name; } default_guids[] = { { {0xb610bc70,{0x377e, 0x11d6, 0xaeb3}, {0x00, 0x01, 0x02, 0x31, 0x5f, 0xfd}}, "Hiker" diff --git a/gpsbabel/avltree.c b/gpsbabel/avltree.c index 121277f39..388f7fcc0 100644 --- a/gpsbabel/avltree.c +++ b/gpsbabel/avltree.c @@ -768,9 +768,9 @@ avltree_save_key(avltree_t *tree, const char *key) if (n8 > tree->key_sz) { if (tree->key_sz == 0) { - tree->key = xmalloc(n8); + tree->key = (char*) xmalloc(n8); } else { - tree->key = xrealloc((char *)tree->key, n8); + tree->key = (char *) xrealloc((char *)tree->key, n8); } tree->key_sz = n8; } diff --git a/gpsbabel/cet/ansi_x3_4_1968.h b/gpsbabel/cet/ansi_x3_4_1968.h index 3305fb6bf..5ecb94bf1 100644 --- a/gpsbabel/cet/ansi_x3_4_1968.h +++ b/gpsbabel/cet/ansi_x3_4_1968.h @@ -37,11 +37,11 @@ const char *cet_cs_alias_ansi_x3_4_1968[] = #define cet_ucs4_ofs_ansi_x3_4_1968 128 #define cet_ucs4_cnt_ansi_x3_4_1968 1 -const int cet_ucs4_map_ansi_x3_4_1968[cet_ucs4_cnt_ansi_x3_4_1968]; +const int cet_ucs4_map_ansi_x3_4_1968[cet_ucs4_cnt_ansi_x3_4_1968] = {}; #define cet_ucs4_to_ansi_x3_4_1968_ct 1 -const cet_ucs4_link_t cet_ucs4_to_ansi_x3_4_1968_links[cet_ucs4_to_ansi_x3_4_1968_ct]; +const cet_ucs4_link_t cet_ucs4_to_ansi_x3_4_1968_links[cet_ucs4_to_ansi_x3_4_1968_ct] = {}; // #define cet_ucs4_to_ansi_x3_4_1968_extra_ct 200 diff --git a/gpsbabel/cet/ibm891.h b/gpsbabel/cet/ibm891.h index 2d0f3a6ab..820e0439b 100644 --- a/gpsbabel/cet/ibm891.h +++ b/gpsbabel/cet/ibm891.h @@ -34,11 +34,11 @@ const char *cet_cs_alias_ibm891[] = #define cet_ucs4_ofs_ibm891 128 #define cet_ucs4_cnt_ibm891 1 -const int cet_ucs4_map_ibm891[cet_ucs4_cnt_ibm891]; +const int cet_ucs4_map_ibm891[cet_ucs4_cnt_ibm891] = {}; #define cet_ucs4_to_ibm891_ct 1 -const cet_ucs4_link_t cet_ucs4_to_ibm891_links[cet_ucs4_to_ibm891_ct]; +const cet_ucs4_link_t cet_ucs4_to_ibm891_links[cet_ucs4_to_ibm891_ct] = {}; /* #define cet_ucs4_to_ibm891_extra_ct 0 diff --git a/gpsbabel/cet/ibm903.h b/gpsbabel/cet/ibm903.h index b9a4d6c19..c7711cdd8 100644 --- a/gpsbabel/cet/ibm903.h +++ b/gpsbabel/cet/ibm903.h @@ -34,11 +34,11 @@ const char *cet_cs_alias_ibm903[] = #define cet_ucs4_ofs_ibm903 128 #define cet_ucs4_cnt_ibm903 1 -const int cet_ucs4_map_ibm903[cet_ucs4_cnt_ibm903]; +const int cet_ucs4_map_ibm903[cet_ucs4_cnt_ibm903] = {}; #define cet_ucs4_to_ibm903_ct 1 -const cet_ucs4_link_t cet_ucs4_to_ibm903_links[cet_ucs4_to_ibm903_ct]; +const cet_ucs4_link_t cet_ucs4_to_ibm903_links[cet_ucs4_to_ibm903_ct] = {}; /* #define cet_ucs4_to_ibm903_extra_ct 0 diff --git a/gpsbabel/cet/iso_8859_1.h b/gpsbabel/cet/iso_8859_1.h index 7df74cc0c..092b69513 100644 --- a/gpsbabel/cet/iso_8859_1.h +++ b/gpsbabel/cet/iso_8859_1.h @@ -37,11 +37,11 @@ const char *cet_cs_alias_iso_8859_1[] = #define cet_ucs4_ofs_iso_8859_1 256 #define cet_ucs4_cnt_iso_8859_1 1 -const int cet_ucs4_map_iso_8859_1[cet_ucs4_cnt_iso_8859_1]; +const int cet_ucs4_map_iso_8859_1[cet_ucs4_cnt_iso_8859_1] = {}; #define cet_ucs4_to_iso_8859_1_ct 1 -const cet_ucs4_link_t cet_ucs4_to_iso_8859_1_links[cet_ucs4_to_iso_8859_1_ct]; +const cet_ucs4_link_t cet_ucs4_to_iso_8859_1_links[cet_ucs4_to_iso_8859_1_ct] = {}; /* #define cet_ucs4_to_iso_8859_1_extra_ct 0 diff --git a/gpsbabel/cet_util.c b/gpsbabel/cet_util.c index 4eee51593..612a77217 100644 --- a/gpsbabel/cet_util.c +++ b/gpsbabel/cet_util.c @@ -402,8 +402,8 @@ cet_check_cs(cet_cs_vec_t *vec) /* test well sorted link & extra tables */ static signed int cet_cs_alias_qsort_cb(const void *a, const void *b) { - const cet_cs_alias_t *va = a; - const cet_cs_alias_t *vb = b; + const cet_cs_alias_t *va = (const cet_cs_alias_t*) a; + const cet_cs_alias_t *vb = (const cet_cs_alias_t*) b; return case_ignore_strcmp(va->name, vb->name); } @@ -444,6 +444,7 @@ cet_cs_vec_t cet_cs_vec_utf8 = { 0, NULL, /* extra */ 0, /* extras */ + NULL, NULL }; @@ -815,7 +816,7 @@ cet_register(void) } /* create name to vec table */ - list = xcalloc(c, sizeof(*list)); + list = (cet_cs_alias_t*) xcalloc(c, sizeof(*list)); i = 0; for (p = cet_cs_vec_root; p != NULL; p = p->next) { if (p->alias != NULL) { diff --git a/gpsbabel/cetus.c b/gpsbabel/cetus.c index 0ea21be8f..bbbf9a56a 100644 --- a/gpsbabel/cetus.c +++ b/gpsbabel/cetus.c @@ -624,7 +624,7 @@ data_write(void) * Turns out plain old strcmp will do the trick... */ - htable = xmalloc(ct * sizeof(*htable)); + htable = (struct hdr*) xmalloc(ct * sizeof(*htable)); bh = htable; QUEUE_FOR_EACH(&waypt_head, elem, tmp) { @@ -652,7 +652,7 @@ data_write(void) ff_vecs_t cetus_vecs = { ff_type_file, - { ff_cap_write | ff_cap_read, ff_cap_read, ff_cap_none }, + { (ff_cap) (ff_cap_write | ff_cap_read), ff_cap_read, ff_cap_none }, rd_init, wr_init, rd_deinit, diff --git a/gpsbabel/copilot.c b/gpsbabel/copilot.c index d0ac4c3fa..2438471e5 100644 --- a/gpsbabel/copilot.c +++ b/gpsbabel/copilot.c @@ -251,7 +251,7 @@ copilot_writewpt(const waypoint *wpt) struct record4 *rec; char *vdata; - rec = xcalloc(sizeof(*rec)+1141,1); + rec = (struct record4 *) xcalloc(sizeof(*rec)+1141,1); pdb_write_double(&rec->latitude, RAD(wpt->latitude)); pdb_write_double(&rec->longitude, RAD(-wpt->longitude)); diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index b0159afbf..4b758434e 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -754,7 +754,7 @@ xcsv_file_init(void) */ xcsv_file.type = ff_type_file; - xcsv_file.mkshort_handle = (struct short_handle *) mkshort_new_handle(); + xcsv_file.mkshort_handle = mkshort_new_handle(); xcsv_file.gps_datum = GPS_DATUM_WGS84; } diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 7377c0656..466ec7150 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -625,10 +625,27 @@ void track_recompute(const route_head *trk, computed_trkdata **); * All shortname functions take a shortname handle as the first arg. * This is an opaque pointer. Callers must not fondle the contents of it. */ -typedef struct short_handle * short_handle; +// This is a crutch until the new C++ shorthandle goes in. +#define PRIME 37 +typedef struct { + unsigned int target_len; + char *badchars; + char *goodchars; + char *defname; + queue namelist[PRIME]; + + /* Various internal flags at end to allow alignment flexibility. */ + unsigned int mustupper:1; + unsigned int whitespaceok:1; + unsigned int repeating_whitespaceok:1; + unsigned int must_uniq:1; + unsigned int is_utf8:1; +} mkshort_handle_imp; +typedef mkshort_handle_imp* short_handle; + #ifndef DEBUG_MEM char *mkshort(short_handle, const char *); -void *mkshort_new_handle(void); +short_handle mkshort_new_handle(void); #else char *MKSHORT(short_handle, const char *, DEBUG_PARAMS); void *MKSHORT_NEW_HANDLE(DEBUG_PARAMS); @@ -652,7 +669,7 @@ void setshort_is_utf8(short_handle h, const int is_utf8); */ #define VMFL_NOZERO (1 << 0) typedef struct vmem { - void *mem; /* visible memory object */ + char *mem; /* visible memory object */ size_t size; /* allocated size of object */ } vmem_t; vmem_t vmem_alloc(size_t, int flags); @@ -727,10 +744,10 @@ typedef enum { } ff_cap; #define FF_CAP_RW_ALL \ - { ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write } + { (ff_cap) (ff_cap_read | ff_cap_write), (ff_cap) (ff_cap_read | ff_cap_write), (ff_cap) (ff_cap_read | ff_cap_write) } #define FF_CAP_RW_WPT \ - { ff_cap_read | ff_cap_write, ff_cap_none, ff_cap_none} + { (ff_cap) (ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none} /* * Format capabilities for realtime positioning. diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 0f57f8b08..72175aa2f 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -105,7 +105,7 @@ rw_init(const char *fname) { int receiver_short_length; int receiver_must_upper = 1; - char * receiver_charset = NULL; + const char * receiver_charset = NULL; if (!mkshort_handle) { mkshort_handle = mkshort_new_handle(); @@ -893,7 +893,7 @@ waypoint_prepare(void) extern queue waypt_head; int icon; - tx_waylist = xcalloc(n,sizeof(*tx_waylist)); + tx_waylist = (struct GPS_SWay**) xcalloc(n,sizeof(*tx_waylist)); for (i = 0; i < n; i++) { tx_waylist[i] = sane_GPS_Way_New(); @@ -1104,7 +1104,7 @@ route_write(void) int i; int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ - tx_routelist = xcalloc(n,sizeof(GPS_PWay)); + tx_routelist = (struct GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); cur_tx_routelist_entry = tx_routelist; for (i = 0; i < n; i++) { @@ -1150,7 +1150,7 @@ track_prepare(void) int i; int32 n = track_waypt_count() + track_count(); - tx_tracklist = xcalloc(n, sizeof(GPS_PTrack)); + tx_tracklist = (struct GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); cur_tx_tracklist_entry = tx_tracklist; for (i = 0; i < n; i++) { tx_tracklist[i] = GPS_Track_New(); diff --git a/gpsbabel/garmin_device_xml.c b/gpsbabel/garmin_device_xml.c index 6f55ce9ce..f2cb8c880 100644 --- a/gpsbabel/garmin_device_xml.c +++ b/gpsbabel/garmin_device_xml.c @@ -45,7 +45,7 @@ void device_s(const char *args, const char **unused) if (my_gdx_info) { fatal(MYNAME ": More than one device type found in file.\n"); } - my_gdx_info = xcalloc(sizeof *my_gdx_info, 1); + my_gdx_info = (gdx_info*) xcalloc(sizeof *my_gdx_info, 1); my_gdx_info->device_desc = xstrdup(args); } @@ -116,7 +116,7 @@ static xg_tag_mapping gdx_map[] = { { ext_s, cb_cdata, "/Device/MassStorageMode/DataType/File/Location/FileExtension" }, { base_s, cb_cdata, "/Device/MassStorageMode/DataType/File/Location/BaseName" }, { dir_s, cb_cdata, "/Device/MassStorageMode/DataType/File/TransferDirection" }, - { 0, 0, NULL } + { 0, (xg_cb_type) 0, NULL } }; const gdx_info * diff --git a/gpsbabel/garmin_tables.c b/gpsbabel/garmin_tables.c index 3c58cff64..73cebf770 100644 --- a/gpsbabel/garmin_tables.c +++ b/gpsbabel/garmin_tables.c @@ -616,7 +616,7 @@ grid_mapping_t gt_mps_grid_names[] = { { "bng", "British National Grid", grid_bng }, { "utm", "UTM", grid_utm }, { "swiss", "Swiss grid", grid_swiss }, - { NULL, NULL, 0 } + { NULL, NULL, (grid_type) 0 } }; /* gt_mps_datum_names: */ diff --git a/gpsbabel/gbfile.c b/gpsbabel/gbfile.c index be19f3815..2fd835e5b 100644 --- a/gpsbabel/gbfile.c +++ b/gpsbabel/gbfile.c @@ -84,9 +84,9 @@ gzapi_open(gbfile *self, const char *mode) fd = stdout; } SET_BINARY_MODE(fd); - self->handle.gz = gzdopen(fileno(fd), openmode); + self->handle.gz = (void **)gzdopen(fileno(fd), openmode); } else { - self->handle.gz = gzopen(self->name, openmode); + self->handle.gz = (void **)gzopen(self->name, openmode); } if (self->handle.gz == NULL) { @@ -131,7 +131,7 @@ static gbsize_t gzapi_read(void *buf, const gbsize_t size, const gbsize_t members, gbfile *self) { int result = 0; - char *target = buf; + char *target = (char*) buf; int count = size * members; if (self->back != -1) { @@ -430,7 +430,7 @@ memapi_write(const void *buf, const gbsize_t size, const gbsize_t members, gbfil if (self->mempos + count > self->memsz) { self->memsz = ((self->mempos + count + 4095) / 4096) * 4096; - self->handle.mem = xrealloc(self->handle.mem, self->memsz); + self->handle.mem = (unsigned char*) xrealloc(self->handle.mem, self->memsz); } memcpy(self->handle.mem + self->mempos, buf, count); self->mempos += count; @@ -497,7 +497,7 @@ gbfopen(const char *filename, const char *mode, const char *module) const char *m; int len; - file = xcalloc(1, sizeof(*file)); + file = (gbfile*) xcalloc(1, sizeof(*file)); file->module = xstrdup(module); file->mode = 'r'; // default @@ -589,7 +589,7 @@ gbfopen(const char *filename, const char *mode, const char *module) #else file->buffsz = 256; #endif - file->buff = xmalloc(file->buffsz); + file->buff = (char *) xmalloc(file->buffsz); return file; } @@ -728,7 +728,7 @@ int gbvfprintf(gbfile *file, const char *format, va_list ap) file->buffsz *= 2; } - file->buff = xrealloc(file->buff, file->buffsz); + file->buff = (char*) xrealloc(file->buff, file->buffsz); } return gbfwrite(file->buff, 1, len, file); } @@ -971,7 +971,7 @@ gbfgetcstr(gbfile *file) if (len == file->buffsz) { file->buffsz += 64; - str = file->buff = xrealloc(file->buff, file->buffsz + 1); + str = file->buff = (char*) xrealloc(file->buff, file->buffsz + 1); } str[len] = c; len++; @@ -998,7 +998,7 @@ gbfgetpstr(gbfile *file) char *result; len = gbfgetc(file); - result = xmalloc(len + 1); + result = (char *) xmalloc(len + 1); if (len > 0) { gbfread(result, 1, len, file); } @@ -1061,7 +1061,7 @@ gbfgetucs2str(gbfile *file) if (len+clen >= file->buffsz) { file->buffsz += 64; - result = file->buff = xrealloc(file->buff, file->buffsz + 1); + result = file->buff = (char*) xrealloc(file->buff, file->buffsz + 1); } memcpy(&result[len], buff, clen); len += clen; @@ -1125,7 +1125,7 @@ gbfgetstr(gbfile *file) if ((len + 1) == file->buffsz) { file->buffsz += 64; - result = file->buff = xrealloc(file->buff, file->buffsz + 1); + result = file->buff = (char*) xrealloc(file->buff, file->buffsz + 1); } result[len] = (char)c; len++; diff --git a/gpsbabel/gbser_posix.c b/gpsbabel/gbser_posix.c index c3ecbf378..39b957b25 100644 --- a/gpsbabel/gbser_posix.c +++ b/gpsbabel/gbser_posix.c @@ -443,7 +443,7 @@ const char *fix_win_serial_name(const char *comname) */ int gbser_read_line(void *handle, void *buf, unsigned len, unsigned ms, int eol, int discard) { - char *bp = buf; + char *bp = (char *) buf; unsigned pos = 0; hp_time tv; get_time(&tv); diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index d380d6406..28597b551 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -67,7 +67,7 @@ xg_tag_mapping loc_map[] = { { wpt_diff, cb_cdata, "/loc/waypoint/difficulty" }, { wpt_terr, cb_cdata, "/loc/waypoint/terrain" }, { wpt_container,cb_cdata, "/loc/waypoint/container" }, - { NULL, 0, NULL } + { NULL, (xg_cb_type)0, NULL } }; void wpt_s(const char *args, const char **unused) @@ -308,7 +308,7 @@ geo_write(void) ff_vecs_t geo_vecs = { ff_type_file, - { ff_cap_read | ff_cap_write, ff_cap_none, ff_cap_none }, + { (ff_cap) (ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none }, geo_rd_init, geo_wr_init, geo_rd_deinit, diff --git a/gpsbabel/gpspilot.c b/gpsbabel/gpspilot.c index 4ab38c731..a53cdc477 100644 --- a/gpsbabel/gpspilot.c +++ b/gpsbabel/gpspilot.c @@ -163,7 +163,7 @@ gpspilot_writewpt(const waypoint *wpt) struct record *rec; char *vdata; - rec = xcalloc(sizeof(*rec)+206,1); + rec = (struct record*) xcalloc(sizeof(*rec)+206,1); be_write32(&rec->longitude, si_round(wpt->longitude * 3.6e6)); be_write32(&rec->latitude, si_round(wpt->latitude * 3.6e6)); diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index a4cf441fe..834654d1d 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -190,7 +190,7 @@ typedef enum { } tag_type; typedef struct { - queue queue; + struct queue queue; char *tagdata; } gpx_global_entry; @@ -222,7 +222,7 @@ gpx_add_to_global(gpx_global_entry *ge, char *cdata) } } - gep = xcalloc(sizeof(*gep), 1); + gep = (gpx_global_entry*) xcalloc(sizeof(*gep), 1); QUEUE_INIT(&gep->queue); gep->tagdata = xstrdup(cdata); ENQUEUE_TAIL(&ge->queue, &gep->queue); @@ -266,7 +266,7 @@ gpx_write_gdata(gpx_global_entry *ge, const char *tag) typedef struct tag_mapping { - tag_type tag_type; /* enum from above for this tag */ + tag_type tag_type_; /* enum from above for this tag */ int tag_passthrough; /* true if we don't generate this */ const char *tag_name; /* xpath-ish tag name */ unsigned long crc; /* Crc32 of tag_name */ @@ -404,7 +404,7 @@ tag_mapping tag_path_map[] = { { tt_vdop, 0, "/gpx/wpt/vdop", 0UL }, { tt_vdop, 0, "/gpx/trk/trkseg/trkpt/vdop", 0UL }, { tt_vdop, 0, "/gpx/rte/rtept/hdop", 0UL }, - {0, 0, NULL, 0UL} + {(tag_type)0, 0, NULL, 0UL} }; static tag_type @@ -413,10 +413,10 @@ get_tag(const char *t, int *passthrough) tag_mapping *tm; unsigned long tcrc = get_crc32_s(t); - for (tm = tag_path_map; tm->tag_type != 0; tm++) { + for (tm = tag_path_map; tm->tag_type_ != 0; tm++) { if ((tcrc == tm->crc) && (0 == strcmp(tm->tag_name, t))) { *passthrough = tm->tag_passthrough; - return tm->tag_type; + return tm->tag_type_; } } *passthrough = 1; @@ -427,7 +427,7 @@ static void prescan_tags(void) { tag_mapping *tm; - for (tm = tag_path_map; tm->tag_type != 0; tm++) { + for (tm = tag_path_map; tm->tag_type_ != 0; tm++) { tm->crc = get_crc32_s(tm->tag_name); } } @@ -627,7 +627,7 @@ tag_log_wpt(const char **attrv) if ((wpt_tmp->shortname) && (strlen(wpt_tmp->shortname) > 2)) { /* copy of the shortname */ - lwp_tmp->shortname = xcalloc(7, 1); + lwp_tmp->shortname = (char *) xcalloc(7, 1); sprintf(lwp_tmp->shortname, "%-4.4s%02d", &wpt_tmp->shortname[2], logpoint_ct++); @@ -1129,7 +1129,7 @@ gpx_end(void *data, const XML_Char *xml_el) wpt_tmp->sat = atof(cdatastrp); break; case tt_fix: - wpt_tmp->fix = atoi(cdatastrp)-1; + wpt_tmp->fix = (fix_type)(atoi(cdatastrp)-1); if (wpt_tmp->fix < fix_2d) { if (!case_ignore_strcmp(cdatastrp, "none")) { wpt_tmp->fix = fix_none; @@ -1226,7 +1226,7 @@ gpx_cdata(void *dta, const XML_Char *xml_el, int len) cdatalen = &(cur_tag->cdatalen); } estr = *cdata; - *cdata = xrealloc(*cdata, *cdatalen + len + 1); + *cdata = (char*) xrealloc(*cdata, *cdatalen + len + 1); estr = *cdata + *cdatalen; memcpy(estr, s, len); *(estr+len) = '\0'; @@ -1273,7 +1273,7 @@ gpx_rd_init(const char *fname) } if (NULL == gpx_global) { - gpx_global = xcalloc(sizeof(*gpx_global), 1); + gpx_global = (struct gpx_global*) xcalloc(sizeof(*gpx_global), 1); QUEUE_INIT(&gpx_global->name.queue); QUEUE_INIT(&gpx_global->desc.queue); QUEUE_INIT(&gpx_global->author.queue); @@ -1347,7 +1347,7 @@ gpx_read(void) #if HAVE_LIBEXPAT int len; int done = 0; - char *buf = xmalloc(MY_CBUF_SZ); + char *buf = (char*) xmalloc(MY_CBUF_SZ); int result = 0; int extra; diff --git a/gpsbabel/gtm.c b/gpsbabel/gtm.c index 4db74f355..4a23fa6ac 100644 --- a/gpsbabel/gtm.c +++ b/gpsbabel/gtm.c @@ -78,7 +78,7 @@ fread_string(gbfile *fd) return NULL; } - val = xmalloc(len+1); + val = (char *) xmalloc(len+1); gbfread(val, 1, len, fd); while (len != 0 && val[len-1] == ' ') { len--; @@ -100,7 +100,7 @@ fread_string_discard(gbfile *fd) static char * fread_fixedstring(gbfile *fd, int len) { - char *val = xmalloc(len+1); + char *val = (char *) xmalloc(len+1); gbfread(val, 1, len, fd); while (len != 0 && val[len-1] == ' ') { diff --git a/gpsbabel/inifile.c b/gpsbabel/inifile.c index 59e802e03..16a03c677 100644 --- a/gpsbabel/inifile.c +++ b/gpsbabel/inifile.c @@ -63,7 +63,7 @@ find_gpsbabel_inifile(const char *path) /* can be empty or NULL */ } len = strlen(path); - buff = xmalloc(len + 1 + strlen(GPSBABEL_INIFILE) + 1); + buff = (char*) xmalloc(len + 1 + strlen(GPSBABEL_INIFILE) + 1); strcpy(buff, path); if (len > 0) { char test = buff[len - 1]; @@ -120,7 +120,7 @@ open_gpsbabel_inifile(void) if ((envstr = getenv("HOME")) != NULL) { char *path; - path = xmalloc(strlen(envstr) + 11); + path = (char*) xmalloc(strlen(envstr) + 11); strcpy(path, envstr); strcat(path, "/.gpsbabel"); name = find_gpsbabel_inifile(path); diff --git a/gpsbabel/itracku.c b/gpsbabel/itracku.c index e0d69b598..8c0134f01 100644 --- a/gpsbabel/itracku.c +++ b/gpsbabel/itracku.c @@ -117,7 +117,7 @@ static const char* itracku_device_read_string() { const int size = 1024; - char* s = xmalloc(size); + char* s = (char*) xmalloc(size); gbser_read_line(fd, s, size, 1000, 0, 0); dbg(1, "read from device: %s", s); return s; @@ -788,8 +788,8 @@ ff_vecs_t itracku_vecs = { ff_vecs_t itracku_fvecs = { ff_type_file, { - ff_cap_read | ff_cap_write /* waypoints */, - ff_cap_read | ff_cap_write /* tracks */, + (ff_cap) (ff_cap_read | ff_cap_write) /* waypoints */, + (ff_cap) (ff_cap_read | ff_cap_write) /* tracks */, ff_cap_none /* routes */ }, itracku_rd_init, diff --git a/gpsbabel/jeeps/garminusb.h b/gpsbabel/jeeps/garminusb.h index 44cd53481..789bfc0e4 100644 --- a/gpsbabel/jeeps/garminusb.h +++ b/gpsbabel/jeeps/garminusb.h @@ -46,13 +46,15 @@ union { * OS implementation. */ #define GUSB_MAX_UNITS 20 -struct garmin_unit_info { +typedef struct { unsigned long serial_number; unsigned long unit_id; unsigned long unit_version; char *os_identifier; /* In case the OS has another name for it. */ char *product_identifier; /* From the hardware itself. */ -} garmin_unit_info[GUSB_MAX_UNITS]; +} garmin_unit_info_t; + +extern garmin_unit_info_t garmin_unit_info[GUSB_MAX_UNITS]; int gusb_cmd_send(const garmin_usb_packet *obuf, size_t sz); int gusb_cmd_get(garmin_usb_packet *ibuf, size_t sz); diff --git a/gpsbabel/jeeps/gps.h b/gpsbabel/jeeps/gps.h index 48c0e9136..d2e250c71 100644 --- a/gpsbabel/jeeps/gps.h +++ b/gpsbabel/jeeps/gps.h @@ -1,6 +1,6 @@ #ifdef __cplusplus -extern "C" -{ +// extern "C" +//{ #endif #ifndef gps_h @@ -263,9 +263,9 @@ extern "C" #include "gpsinput.h" #include "gpsproj.h" - time_t gps_save_time; - double gps_save_lat; - double gps_save_lon; + extern time_t gps_save_time; + extern double gps_save_lat; + extern double gps_save_lon; extern int32 gps_save_id; extern double gps_save_version; extern char gps_save_string[GPS_ARB_LEN]; @@ -284,5 +284,5 @@ extern "C" #endif #ifdef __cplusplus -} +// } #endif diff --git a/gpsbabel/jeeps/gpsapp.c b/gpsbabel/jeeps/gpsapp.c index 21c5f0b39..293d8bfe2 100644 --- a/gpsbabel/jeeps/gpsapp.c +++ b/gpsbabel/jeeps/gpsapp.c @@ -37,6 +37,10 @@ #include "garminusb.h" #include "gpsusbint.h" +time_t gps_save_time; +double gps_save_lat; +double gps_save_lon; + #define XMIN(a,b) (a < b? a : b) static int32 GPS_A000(const char *port); @@ -7855,7 +7859,7 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack **trk, int32 *n) trkpt->distance_populated = 0; trkpt->heartrate = 0; trkpt->cadence = 0xff; - *trk = xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); + *trk = (struct GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); memmove(&(*trk)[i+1], &(*trk)[i], (*n-i) * sizeof(GPS_PTrack)); (*trk)[i] = trkpt; i++; diff --git a/gpsbabel/jeeps/gpscom.c b/gpsbabel/jeeps/gpscom.c index 06ce93a9e..eba4af141 100644 --- a/gpsbabel/jeeps/gpscom.c +++ b/gpsbabel/jeeps/gpscom.c @@ -1194,7 +1194,7 @@ int32 GPS_Command_Send_Track_As_Course(const char *port, GPS_PTrack *trk, int32 } /* Create & append course */ - crs = xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); + crs = (struct GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); crs[n_crs] = GPS_Course_New(); if (!crs[n_crs]) { return MEMORY_ERROR; @@ -1207,7 +1207,7 @@ int32 GPS_Command_Send_Track_As_Course(const char *port, GPS_PTrack *trk, int32 crs[n_crs]->track_index = Unique_Track_Index(crs, n_crs); /* Create & append new lap */ - clp = xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); + clp = (struct GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); clp[n_clp] = GPS_Course_Lap_New(); if (!clp[n_clp]) { return MEMORY_ERROR; @@ -1221,7 +1221,7 @@ int32 GPS_Command_Send_Track_As_Course(const char *port, GPS_PTrack *trk, int32 } /* Append new track points */ - ctk = xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); + ctk = (struct GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); first_new_ctk = n_ctk; for (i=0; iishdr && (i>=n_trk || trk[i+1]->ishdr)) { @@ -1246,7 +1246,7 @@ int32 GPS_Command_Send_Track_As_Course(const char *port, GPS_PTrack *trk, int32 /* Convert waypoints to course points by searching closest track point & * append */ - cpt = xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); + cpt = (struct GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); for (i=0; i diff --git a/gpsbabel/jeeps/gpsprot.h b/gpsbabel/jeeps/gpsprot.h index 4b1aff75a..3de616848 100644 --- a/gpsbabel/jeeps/gpsprot.h +++ b/gpsbabel/jeeps/gpsprot.h @@ -6,6 +6,10 @@ extern "C" #ifndef gpsprotocols_h #define gpsprotocols_h +#ifndef COMMON +#define COMMON extern +#endif + #include "gps.h" /* @@ -63,7 +67,7 @@ extern "C" #define pA010 10 #define pA011 11 - int32 gps_device_command; + COMMON int32 gps_device_command; struct COMMANDDATA { @@ -101,20 +105,20 @@ extern "C" * Waypoint Transfer Protocol */ #define pA100 100 - int32 gps_waypt_transfer; + COMMON int32 gps_waypt_transfer; /* * Waypoint category transfer protocol */ #define pA101 101 - int32 gps_category_transfer; + COMMON int32 gps_category_transfer; /* * Route Transfer Protocol */ #define pA200 200 #define pA201 201 - int32 gps_route_transfer; + COMMON int32 gps_route_transfer; /* * Track Log Transfer Protocol @@ -123,26 +127,26 @@ extern "C" #define pA301 301 #define pA302 302 #define pA304 304 - int32 gps_trk_transfer; + COMMON int32 gps_trk_transfer; /* * Proximity Waypoint Transfer Protocol */ #define pA400 400 - int32 gps_prx_waypt_transfer; + COMMON int32 gps_prx_waypt_transfer; /* * Almanac Transfer Protocol */ #define pA500 500 - int32 gps_almanac_transfer; + COMMON int32 gps_almanac_transfer; /* * Date Time Transfer */ #define pA600 600 - int32 gps_date_time_transfer; + COMMON int32 gps_date_time_transfer; /* * FlightBook Transfer Protocol @@ -154,42 +158,42 @@ extern "C" * Position */ #define pA700 700 - int32 gps_position_transfer; + COMMON int32 gps_position_transfer; /* * Pvt */ #define pA800 800 - int32 gps_pvt_transfer; + COMMON int32 gps_pvt_transfer; /* * Lap Data Transfer */ #define pA906 906 - int32 gps_lap_transfer; + COMMON int32 gps_lap_transfer; /* * Various fitness related */ #define pA1000 1000 - int32 gps_run_transfer; + COMMON int32 gps_run_transfer; #define pA1002 1002 - int32 gps_workout_transfer; + COMMON int32 gps_workout_transfer; #define pA1004 1004 - int32 gps_user_profile_transfer; + COMMON int32 gps_user_profile_transfer; #define pA1005 1005 - int32 gps_workout_limits_transfer; + COMMON int32 gps_workout_limits_transfer; #define pA1006 1006 - int32 gps_course_transfer; + COMMON int32 gps_course_transfer; #define pA1007 1007 - int32 gps_course_lap_transfer; + COMMON int32 gps_course_lap_transfer; #define pA1008 1008 - int32 gps_course_point_transfer; + COMMON int32 gps_course_point_transfer; #define pA1009 1009 - int32 gps_course_limits_transfer; + COMMON int32 gps_course_limits_transfer; #define pA1012 1012 - int32 gps_course_trk_transfer; + COMMON int32 gps_course_trk_transfer; /* * Waypoint D Type @@ -211,14 +215,14 @@ extern "C" #define pD154 154 #define pD155 155 - int32 gps_rte_type; - int32 gps_waypt_type; + COMMON int32 gps_rte_type; + COMMON int32 gps_waypt_type; /* * Waypoint category types */ #define pD120 120 - int32 gps_category_type; + COMMON int32 gps_category_type; /* * Rte Header Type @@ -226,14 +230,14 @@ extern "C" #define pD200 200 #define pD201 201 #define pD202 202 - int32 gps_rte_hdr_type; + COMMON int32 gps_rte_hdr_type; /* * Rte Link Type */ #define pD210 210 - int32 gps_rte_link_type; + COMMON int32 gps_rte_link_type; /* @@ -244,8 +248,8 @@ extern "C" #define pD302 302 #define pD303 303 #define pD304 304 - int32 gps_trk_type; - int32 gps_run_crs_trk_type; + COMMON int32 gps_trk_type; + COMMON int32 gps_run_crs_trk_type; /* @@ -254,8 +258,8 @@ extern "C" #define pD310 310 #define pD311 311 #define pD312 312 - int32 gps_trk_hdr_type; - int32 gps_run_crs_trk_hdr_type; + COMMON int32 gps_trk_hdr_type; + COMMON int32 gps_run_crs_trk_hdr_type; @@ -266,7 +270,7 @@ extern "C" #define pD403 403 #define pD450 450 - int32 gps_prx_waypt_type; + COMMON int32 gps_prx_waypt_type; /* @@ -277,7 +281,7 @@ extern "C" #define pD550 550 #define pD551 551 - int32 gps_almanac_type; + COMMON int32 gps_almanac_type; /* @@ -285,7 +289,7 @@ extern "C" */ #define pD600 600 - int32 gps_date_time_type; + COMMON int32 gps_date_time_type; @@ -294,7 +298,7 @@ extern "C" */ #define pD700 700 - int32 gps_position_type; + COMMON int32 gps_position_type; @@ -303,7 +307,7 @@ extern "C" */ #define pD800 800 - int32 gps_pvt_type; + COMMON int32 gps_pvt_type; /* * Lap Data Type @@ -313,7 +317,7 @@ extern "C" #define pD1011 1011 #define pD1015 1015 - int32 gps_lap_type; + COMMON int32 gps_lap_type; /* * Various fitness related @@ -321,24 +325,24 @@ extern "C" #define pD1000 1000 #define pD1009 1009 #define pD1010 1010 - int32 gps_run_type; + COMMON int32 gps_run_type; #define pD1002 1002 #define pD1008 1008 - int32 gps_workout_type; + COMMON int32 gps_workout_type; #define pD1003 1003 - int32 gps_workout_occurrence_type; + COMMON int32 gps_workout_occurrence_type; #define pD1004 1004 - int32 gps_user_profile_type; + COMMON int32 gps_user_profile_type; #define pD1005 1005 - int32 gps_workout_limits_type; + COMMON int32 gps_workout_limits_type; #define pD1006 1006 - int32 gps_course_type; + COMMON int32 gps_course_type; #define pD1007 1007 - int32 gps_course_lap_type; + COMMON int32 gps_course_lap_type; #define pD1012 1012 - int32 gps_course_point_type; + COMMON int32 gps_course_point_type; #define pD1013 1013 - int32 gps_course_limits_type; + COMMON int32 gps_course_limits_type; /* * Link protocol type @@ -347,7 +351,7 @@ extern "C" #define pL001 1 #define pL002 2 - int32 gps_link_type; + COMMON int32 gps_link_type; @@ -370,7 +374,7 @@ extern "C" ; US GPS_Protocol_Version_Change(US id, US version); - int32 GPS_Protocol_Table_Set(US id); + COMMON int32 GPS_Protocol_Table_Set(US id); void GPS_Protocol_Error(US tag, US data); void GPS_Unknown_Protocol_Print(void); diff --git a/gpsbabel/jeeps/gpsserial.c b/gpsbabel/jeeps/gpsserial.c index cd0c38089..750a410ba 100644 --- a/gpsbabel/jeeps/gpsserial.c +++ b/gpsbabel/jeeps/gpsserial.c @@ -488,7 +488,7 @@ int32 GPS_Serial_Wait(gpsdevh *dh) int32 GPS_Serial_On(const char *port, gpsdevh **dh) { - posix_serial_data *psd = xcalloc(sizeof(posix_serial_data), 1); + posix_serial_data *psd = (posix_serial_data*) xcalloc(sizeof(posix_serial_data), 1); *dh = (gpsdevh*) psd; if (!GPS_Serial_Open((gpsdevh *) psd,port)) { diff --git a/gpsbabel/jeeps/gpsusbcommon.c b/gpsbabel/jeeps/gpsusbcommon.c index 63a299f63..3d37bcfc1 100644 --- a/gpsbabel/jeeps/gpsusbcommon.c +++ b/gpsbabel/jeeps/gpsusbcommon.c @@ -210,7 +210,7 @@ gusb_list_units() } void -gusb_id_unit(struct garmin_unit_info *gu) +gusb_id_unit(garmin_unit_info_t *gu) { static const char oid[12] = {20, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, 0, 0}; diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index a4095ba0d..c6d6329aa 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -51,7 +51,6 @@ static int extrude; static int trackdata; static int trackdirection; static int max_position_points; -static int export_track; static int line_width; static int indent_level; @@ -215,7 +214,7 @@ xg_tag_mapping kml_map[] = { { trk_coord, cb_cdata, "/Placemark/GeometryCollection/LineString/coordinates" }, { trk_coord, cb_cdata, "/Placemark/Polygon/outerBoundaryIs/LinearRing/coordinates" }, { trk_coord, cb_cdata, "/Placemark/LineString/coordinates" }, - { NULL, 0, NULL } + { NULL, (xg_cb_type) 0, NULL } }; static diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index b748d0db6..29b4088b5 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -92,7 +92,7 @@ typedef struct mag_rte_elem { /* * A header of a route. Related elements of a route belong to this. */ -typedef struct mag_rte_head { +typedef struct mag_rte_head_ { queue Q; /* Queue head for child rte_elems */ char *rte_name; int nelems; @@ -225,7 +225,7 @@ static icon_mapping_t *icon_mapping = map330_icon_table; static char * m315_cleanse(char *istring) { - char *rstring = xmalloc(strlen(istring)+1); + char *rstring = (char*) xmalloc(strlen(istring)+1); char *i,*o; static char m315_valid_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"; @@ -247,7 +247,7 @@ m330_cleanse(char *istring) static char m330_valid_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " "abcdefghijklmnopqrstuvwxyz" "0123456789+-.'/!@#<%^&>()=:\\"; - char *rstring = xmalloc(strlen(istring)+1); + char *rstring = (char*) xmalloc(strlen(istring)+1); char *o, *i; for (o=rstring,i=istring; *i; i++) { @@ -618,7 +618,7 @@ mag_dequote(char *ibuf) while ((esc = strchr(ibuf, 0x1b))) { int nremains = strlen(esc); if (nremains >= 3) { - static const char hex[16] = "0123456789ABCDEF"; + static const char hex[17] = "0123456789ABCDEF"; char *c1 = strchr(hex, esc[1]); char *c2 = strchr(hex, esc[2]); if (c1 && c2) { @@ -1063,7 +1063,7 @@ mag_rteparse(char *rtemsg) * queue head. */ if (frag == 1) { - mag_rte_head = xcalloc(sizeof(*mag_rte_head),1); + mag_rte_head = (struct mag_rte_head_*) xcalloc(sizeof(*mag_rte_head),1); QUEUE_INIT(&mag_rte_head->Q); mag_rte_head->nelems = frags; } @@ -1084,7 +1084,7 @@ mag_rteparse(char *rtemsg) *p = '\0'; } - rte_elem = xcalloc(sizeof(*rte_elem),1); + rte_elem = (mag_rte_elem*) xcalloc(sizeof(*rte_elem),1); QUEUE_INIT(&rte_elem->Q); rte_elem->wpt_name = xstrdup(next_stop); @@ -1098,7 +1098,7 @@ mag_rteparse(char *rtemsg) * routepoint. */ if (broken_sportrak && abuf[0]) { - rte_elem = xcalloc(sizeof(*rte_elem),1); + rte_elem = (mag_rte_elem*) xcalloc(sizeof(*rte_elem),1); QUEUE_INIT(&rte_elem->Q); rte_elem->wpt_name = xstrdup(abuf); @@ -1379,7 +1379,7 @@ mag_waypt_pr(const waypoint *waypointp) isrc = waypointp->notes ? waypointp->notes : waypointp->description; owpt = global_opts.synthesize_shortnames ? mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname; - odesc = isrc ? isrc : ""; + odesc = isrc ? isrc : (char *)""; owpt = mag_cleanse(owpt); if (global_opts.smart_icons && @@ -1602,7 +1602,7 @@ mag_write(void) const char ** os_get_magellan_mountpoints() { #if __APPLE__ - const char **dlist = xcalloc(2, sizeof *dlist); + const char **dlist = (const char**) xcalloc(2, sizeof *dlist); dlist[0] = xstrdup("/Volumes/Magellan"); dlist[1] = NULL; return dlist; diff --git a/gpsbabel/make-an1sym.pl b/gpsbabel/make-an1sym.pl index 276699b2a..1b6f47728 100755 --- a/gpsbabel/make-an1sym.pl +++ b/gpsbabel/make-an1sym.pl @@ -278,7 +278,7 @@ print <<'END'; struct defguid { GUID guid; - char *name; + const char *name; } default_guids[] = { END } diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index 0dbac67a2..182939a28 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -1847,7 +1847,7 @@ mps_write(void) fatal(MYNAME ": merge source version is %d, requested out version is %d\n", mps_ver_temp, atoi(mpsverout)); } } else { - mpsverout = xmalloc(10); + mpsverout = (char *) xmalloc(10); sprintf(mpsverout,"%d", mps_ver_temp); } } diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index f177fdc76..2d715bf68 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -42,21 +42,6 @@ static const char *DEFAULT_BADCHARS = "\"$.,'!-"; */ #define PRIME 37 -typedef struct { - unsigned int target_len; - char *badchars; - char *goodchars; - char *defname; - queue namelist[PRIME]; - - /* Various internal flags at end to allow alignment flexibility. */ - unsigned int mustupper:1; - unsigned int whitespaceok:1; - unsigned int repeating_whitespaceok:1; - unsigned int must_uniq:1; - unsigned int is_utf8:1; -} mkshort_handle; - typedef struct { queue list; char *orig_shortname; @@ -93,7 +78,7 @@ unsigned int hash_string(const char *key) return hash; } -void * +short_handle #ifdef DEBUG_MEM MKSHORT_NEW_HANDLE(DEBUG_PARAMS) #else @@ -101,7 +86,7 @@ mkshort_new_handle() #endif { int i; - mkshort_handle *h = (mkshort_handle *) xxcalloc(sizeof *h, 1, file, line); + mkshort_handle_imp *h = (mkshort_handle_imp *) xxcalloc(sizeof *h, 1, file, line); for (i = 0; i < PRIME; i++) { QUEUE_INIT(&h->namelist[i]); @@ -119,7 +104,7 @@ mkshort_new_handle() static uniq_shortname * -is_unique(mkshort_handle *h, char *name) +is_unique(mkshort_handle_imp *h, char *name) { queue *e, *t; int hash; @@ -136,7 +121,7 @@ is_unique(mkshort_handle *h, char *name) static void -add_to_hashlist(mkshort_handle *h, char *name) +add_to_hashlist(mkshort_handle_imp *h, char *name) { int hash = hash_string(name); uniq_shortname *s = (uniq_shortname*) xcalloc(1, sizeof(uniq_shortname)); @@ -146,7 +131,7 @@ add_to_hashlist(mkshort_handle *h, char *name) } char * -mkshort_add_to_list(mkshort_handle *h, char *name) +mkshort_add_to_list(mkshort_handle_imp *h, char *name) { uniq_shortname *s; @@ -174,7 +159,7 @@ mkshort_add_to_list(mkshort_handle *h, char *name) void mkshort_del_handle(short_handle *h) { - mkshort_handle *hdr = (mkshort_handle*) *h; + mkshort_handle_imp *hdr = (mkshort_handle_imp*) *h; int i; if (!h || !hdr) { @@ -275,7 +260,7 @@ replace_constants(char *s) void setshort_length(short_handle h, int l) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; if (l == 0) { hdl->target_len = DEFAULT_TARGET_LEN; } else { @@ -290,7 +275,7 @@ setshort_length(short_handle h, int l) void setshort_whitespace_ok(short_handle h, int l) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; hdl->whitespaceok = l; } @@ -302,7 +287,7 @@ setshort_whitespace_ok(short_handle h, int l) void setshort_repeating_whitespace_ok(short_handle h, int l) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; hdl->repeating_whitespaceok = l; } @@ -313,7 +298,7 @@ setshort_repeating_whitespace_ok(short_handle h, int l) void setshort_defname(short_handle h, const char *s) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; if (s == NULL) { fatal("setshort_defname called without a valid name."); } @@ -331,7 +316,7 @@ setshort_defname(short_handle h, const char *s) void setshort_badchars(short_handle h, const char *s) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; if ((hdl->badchars != NULL)) { xfree(hdl->badchars); @@ -346,7 +331,7 @@ setshort_badchars(short_handle h, const char *s) void setshort_goodchars(short_handle h, const char *s) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; if (hdl->goodchars != NULL) { xfree(hdl->goodchars); @@ -364,7 +349,7 @@ setshort_goodchars(short_handle h, const char *s) void setshort_mustupper(short_handle h, int i) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; hdl->mustupper = i; } @@ -376,7 +361,7 @@ setshort_mustupper(short_handle h, int i) void setshort_mustuniq(short_handle h, int i) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; hdl->must_uniq = i; } @@ -386,7 +371,7 @@ setshort_mustuniq(short_handle h, int i) void setshort_is_utf8(short_handle h, const int is_utf8) { - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; hdl->is_utf8 = is_utf8; } @@ -403,7 +388,7 @@ mkshort(short_handle h, const char *istring) char *cp; char *np; int i, l, nlen, replaced; - mkshort_handle *hdl = (mkshort_handle *) h; + mkshort_handle_imp *hdl = (mkshort_handle_imp *) h; if (hdl->is_utf8) { ostring = cet_utf8_strdup(istring); /* clean UTF-8 string */ diff --git a/gpsbabel/nmea.c b/gpsbabel/nmea.c index 18e608a8e..f55077fda 100644 --- a/gpsbabel/nmea.c +++ b/gpsbabel/nmea.c @@ -335,7 +335,7 @@ nmea_wr_init(const char *portname) } } - mkshort_handle = (struct short_handle*) mkshort_new_handle(); + mkshort_handle = mkshort_new_handle(); setshort_length(mkshort_handle, atoi(snlenopt)); if (opt_gisteq) { diff --git a/gpsbabel/psp.c b/gpsbabel/psp.c index b6114b27f..2008ab798 100644 --- a/gpsbabel/psp.c +++ b/gpsbabel/psp.c @@ -77,7 +77,7 @@ psp_read_str(gbfile *fin) return NULL; } - buff = xmalloc(len * sizeof(*buff)); + buff = (gbint16*) xmalloc(len * sizeof(*buff)); gbfread(buff, sizeof(*buff), len, fin); res = cet_str_uni_to_utf8(buff, len); xfree(buff); diff --git a/gpsbabel/trackfilter.c b/gpsbabel/trackfilter.c index 37eadf77c..f70161f44 100644 --- a/gpsbabel/trackfilter.c +++ b/gpsbabel/trackfilter.c @@ -288,7 +288,7 @@ trackfilter_parse_fix(int *nsats) return fix_none; } fatal(MYNAME ": invalid fix type\n"); - return 0; + return fix_unknown; } static void @@ -932,7 +932,7 @@ trackfilter_seg2trk(void) dest->rte_num = src->rte_num; /* name in the form TRACKNAME #n */ snprintf(trk_seg_num_buf, sizeof(trk_seg_num_buf), "%d", ++trk_seg_num); - dest->rte_name = xmalloc(strlen(src->rte_name)+strlen(trk_seg_num_buf)+3); + dest->rte_name = (char*) xmalloc(strlen(src->rte_name)+strlen(trk_seg_num_buf)+3); sprintf(dest->rte_name, "%s #%s", src->rte_name, trk_seg_num_buf); /* Insert after original track or after last newly diff --git a/gpsbabel/vmem.c b/gpsbabel/vmem.c index 437b9cd4b..64bb5673f 100644 --- a/gpsbabel/vmem.c +++ b/gpsbabel/vmem.c @@ -31,7 +31,7 @@ vmem_alloc(size_t size, int flags) * By default, zero the allocated thingy. */ if (flags & VMFL_NOZERO) { - vm.mem = xmalloc(size); + vm.mem = (char *) xmalloc(size); } else { vm.mem = (char *) xcalloc(size, 1); } @@ -61,7 +61,7 @@ vmem_realloc(vmem_t *vm, size_t size) * Reallocate only if we must. */ if (size > vm->size) { - vm->mem = xrealloc(vm->mem, size); + vm->mem = (char *) xrealloc(vm->mem, size); vm->size = size; } return; diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 4d55a7bab..24bb8c650 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -82,7 +82,7 @@ waypt_dupe(const waypoint *wpt) } if (wpt->gc_data != &empty_gc_data) { - geocache_data *gc_data = xmalloc(sizeof(*gc_data)); + geocache_data *gc_data = (geocache_data*) xmalloc(sizeof(*gc_data)); tmp->gc_data = (const geocache_data *)gc_data; memcpy(gc_data, wpt->gc_data, sizeof(*gc_data)); @@ -522,7 +522,7 @@ waypt_add_url(waypoint *wpt, char *link, char *url_link_text) wpt->url_link_text = url_link_text; } else { url_link *tail; - url_link *new_link = xcalloc(sizeof(url_link), 1); + url_link *new_link = (url_link*) xcalloc(sizeof(url_link), 1); new_link->url = link; new_link->url_link_text = url_link_text; @@ -676,7 +676,7 @@ waypt_alloc_gc_data(waypoint *wpt) { geocache_data *res = (geocache_data *)wpt->gc_data; if (res == &empty_gc_data) { - res = xcalloc(1, sizeof(*res)); + res = (geocache_data*) xcalloc(1, sizeof(*res)); wpt->gc_data = (const geocache_data *)res; } diff --git a/gpsbabel/wbt-200.c b/gpsbabel/wbt-200.c index 7fdd4c86e..849dc2aa7 100644 --- a/gpsbabel/wbt-200.c +++ b/gpsbabel/wbt-200.c @@ -92,9 +92,11 @@ static FILE *fl; static char *port; static char *erase; -static enum { +typedef enum { UNKNOWN, WBT200, WBT201, WSG1000 -} dev_type = UNKNOWN; +} wintec_gps_types; + +static wintec_gps_types dev_type = UNKNOWN; struct buf_chunk { struct buf_chunk *next; @@ -173,7 +175,7 @@ static void buf_rewind(struct buf_head *h) static size_t buf_read(struct buf_head *h, void *data, size_t len) { - char *bp = data; + char *bp = (char *) data; size_t got = 0; while (len != 0 && h->current != NULL) { @@ -206,7 +208,7 @@ static void buf_extend(struct buf_head *h, size_t amt) struct buf_chunk *c; size_t sz = amt + sizeof(struct buf_chunk); - c = xmalloc(sz); + c = (struct buf_chunk*) xmalloc(sz); c->next = NULL; c->size = amt; c->used = 0; @@ -236,7 +238,7 @@ static void buf_update_checksum(struct buf_head *h, const void *data, size_t len static void buf_write(struct buf_head *h, const void *data, size_t len) { size_t avail; - const char *bp = data; + const char *bp = (const char *) data; buf_update_checksum(h, data, len); @@ -370,7 +372,7 @@ static int wsg1000_try() return expect("@AL,2,3,OK"); } -static int guess_device() +static wintec_gps_types guess_device() { int i; db(1, "Guessing device...\n"); -- 2.30.2